package org.wdh.ep.sct.af;
import java.util.NoSuchElementException;

public class LinkedList {
	private List value;
	private LinkedList rest;
	public LinkedList() {
		this.value = new Empty();
	}
	public LinkedList(Object _first) {
		this.value = new Cons(_first);
	}
	public LinkedList(Object _first, LinkedList _rest) {
		this.value = new Cons(_first, _rest.value);
	}
	private LinkedList(List _value) { this.value = _value; }
	public Object getFirst() { return this.value.getFirst();  }
	public LinkedList getRest() { return new LinkedList(this.value.getRest()); }
	public void addFirst(Object o) { this.value = new Cons(o, this.value); }
	public boolean isEmpty() { return this.value instanceof Empty; }
	public boolean equals(Object that) {
		if (this.getClass() == that.getClass()) {
			return this.value.equals(((LinkedList)that).value);
		}
		else {
			return false;
		}
	}
}
